#ifdef WX_PRECOMP
    #include "wx_pch.h"
#else
#endif

#include "snippetitemdata.h"
#include "snippetsconfig.h"
#include "codesnippetswindow.h"


long     SnippetTreeItemData::m_HighestSnippetID = 0;
unsigned SnippetTreeItemData::m_itemsChangedCount = 0;

SnippetTreeItemData::SnippetTreeItemData(SnippetItemType type, SnippetItemID oldID)
    : m_Type(type), m_Snippet(wxEmptyString), m_ID(oldID) {
    InitializeItem(oldID);
}

SnippetTreeItemData::SnippetTreeItemData(SnippetItemType type, wxString snippet, SnippetItemID oldID)
    : m_Type(type), m_Snippet(snippet), m_ID(oldID) {
    InitializeItem(oldID);
}

SnippetTreeItemData::~SnippetTreeItemData() {

}

void SnippetTreeItemData::InitializeItem(SnippetItemID oldID) {
   
    if ( 0 == oldID )
        m_ID = GetNewID();

   
    if ( m_ID < m_HighestSnippetID )
        if ( GetConfig()->GetSnippetsWindow()->IsAppendingFile() )
            m_ID = GetNewID();

    if ( oldID not_eq m_ID )
        m_itemsChangedCount += 1;

   
    UpdateHighestSnippetID(m_ID);
}
